package com.gl.file;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by GaoLei on 14-8-12.
 */
public class ObjectInputAndOutputStream {
    public static void main(String[] args) throws Exception {
        List fileList = new ArrayList<String>();
        fileList.add("使用说明");
        fileList.add("设计文档");
        fileList.add("版本v1.0发布声明");
        Application app1 = new Application();
        app1.setAppId("11");
        app1.setName("检索");
        app1.setStatus(0);//下线
        app1.setType(Application.TYPE_BS);
        app1.setUrl("http://www.ifeng.com/");
        app1.setDescription("描述描述描述描述");
        app1.setFeature("功能功能\n功能功能\n功能");
        app1.setCurrentVersion("V1.0");
        app1.setFiles(fileList);

        Application app2 = new Application();
        app2.setAppId("12");
        app2.setName("编目");
        app2.setStatus(1);//上线
        app2.setType(Application.TYPE_BS);
        app2.setUrl("http://www.ifeng.com/");
        app2.setDescription("编目编目描述描述");
        app2.setFeature("功能功能\n功能功能\n功能");
        app2.setCurrentVersion("V1.0");
        app2.setFiles(fileList);

        Application app3 = new Application();
        app3.setAppId("13");
        app3.setName("下载");
        app3.setStatus(0);//下线
        app3.setType(Application.TYPE_CS);
        app3.setUrl("http://www.ifeng.com/");
        app3.setDescription("下载下载描述描述");
        app3.setFeature("功能功能\n功能功能\n功能");
        app3.setCurrentVersion("V1.0");
        app3.setFiles(fileList);

        Application app4 = new Application();
        app4.setAppId("14");
        app4.setName("收录管理");
        app4.setStatus(0);//下线
        app4.setType(Application.TYPE_CS);
        app4.setUrl("http://www.ifeng.com/");
        app4.setDescription("收录网关收录网关描述描述");
        app4.setFeature("功能功能\n功能功能\n功能");
        app4.setCurrentVersion("V1.0");
        app4.setFiles(fileList);

        Application app5 = new Application();
        app5.setAppId("15");;
        app5.setName("汇聚空间");
        app5.setStatus(0);//下线
        app5.setType(Application.TYPE_BS);
        app5.setUrl("http://www.ifeng.com/");
        app5.setDescription("汇聚空间描述描述");
        app5.setFeature("汇聚空间功能功能\n功能功能\n功能");
        app5.setCurrentVersion("V1.0");
        app5.setFiles(fileList);

        Application app6 = new Application();
        app6.setAppId("16");
        app6.setName("拆条");
        app6.setStatus(0);//下线
        app6.setType(Application.TYPE_CS);
        app6.setUrl("http://www.ifeng.com/");
        app6.setDescription("描述描述");
        app6.setFeature("拆条拆条功能功能\n功能功能\n功能");
        app6.setCurrentVersion("V1.0");
        app6.setFiles(fileList);

        Application app7 = new Application();
        app7.setAppId("17");
        app7.setName("个人空间");
        app7.setStatus(1);//下线
        app7.setType(Application.TYPE_CS);
        app7.setUrl("http://www.ifeng.com/");
        app7.setDescription("个人空间个人空间描述描述");
        app7.setFeature("个人空间功能\n功能功能\n功能");
        app7.setCurrentVersion("V1.0");
        app7.setFiles(fileList);

        List appList = new ArrayList();
        appList.add(app1);
        appList.add(app2);
        appList.add(app3);
        appList.add(app4);
        appList.add(app5);
        appList.add(app6);
        appList.add(app7);
        ( (Application)(appList.get(0)) ).setName("00000");
        
        List appList1 = appList;
        
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("appList.txt"));
        oos.writeObject(appList);

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("appList.txt"));
        List<Application> perList = (List<Application>) ois.readObject();
        System.out.println("appList == appList1:" + (appList == appList1));
        System.out.println(appList == perList);
        System.out.println(perList.size());
        perList.get(0).setName("11111");
        //System.out.println(perList.get(0).setName(""));
        System.out.println(perList.get(1));
    }
}
